/*
 * @Author: yeminglong
 * @Date: 2024-04-28 09:47:02
 * @LastEditTime: 2024-04-28 09:53:42
 * @LastEditors: yeminglong
 * @Description: 系统登陆
 */
import { service } from '@/utils/request.js'
import { isDev } from '@/utils'
const LOGIN_PREFIX = isDev ? '/authlogin' : window.__CTC_ENV__.VUE_APP_LOGIN_PREFIX
export default class LoginServiceApi {
  /**
   * 获取验证码
   * @returns {Promise<unknown>}
   */
  static authCaptchaCode(params = {}) {
    return service({
      url: `${LOGIN_PREFIX}/prod-api/code`,
      method: 'GET',
      params: params
    })
  }

  /**
   * 获取用户信息
   * @returns {Promise<unknown>}
   */
  static getUserInfo(params = {}) {
    return service({
      url: `${LOGIN_PREFIX}/prod-api/system/user/info`,
      method: 'GET',
      params: params
    })
  }
  /**
   * 获取菜单路由地址
   * @returns {Promise<unknown>}
   */
  static getRouters(params = {}) {
    return service({
      url: `${LOGIN_PREFIX}/prod-api/system/menu/getRouters`,
      method: 'GET',
      params: params
    })
  }

  /**
   * 第三方登录 获取token
   * @returns {Promise<unknown>}
   */
  static digitalBaseSso(code = '') {
    return service({
      url: `${LOGIN_PREFIX}/jointsky-ft/digital/base/sso`,
      method: 'GET',
      params: { code }
    })
  }

  /**
   * 登陆获取Token
   * @param {String} ld.code -  验证码
   * @param {String} ld.password -  密码
   * @param {String} ld.username -  账号
   * @param {String} ld.uuid -  验证码唯一标识
   * @returns {Promise<unknown>}
   */
  static authLogin(params = {}) {
    return service({
      url: `${LOGIN_PREFIX}/prod-api/auth/login`,
      method: 'POST',
      data: JSON.stringify(params || {}),
      headers: {
        'Content-Type': 'application/json'
      },
      transformRequest: null
    })
  }
}
